<?php

class SiteController extends Controller {

    public function actionIndex() {
        
//        $page_model = site_page::model()->findByPk(1);
//        
//        $news_criteria = new CDbCriteria;
//        $news_criteria->condition = "news_is_active = '1'";
//        $news_criteria->order = "news_input_datetime DESC";
//        $news_criteria->limit = 5;
//        $news_model = site_news::model()->findAll($news_criteria);
//        
//        $testimony_criteria = new CDbCriteria;
//        $testimony_criteria->condition = "member_testimony_is_approve = '1'";
//        $testimony_criteria->order = "member_testimony_order_by ASC";
//        $testimony_criteria->limit = 5;
//        $testimony_model = sys_member_testimony::model()->findAll($testimony_criteria);
//        
//        $this->render('index', array('page_model' => $page_model, 'news_model' => $news_model, 'testimony_model' => $testimony_model));
        
        $data = site_page::model()->findByPk(1);
        
//        $sql = "SELECT * FROM site_slider ORDER BY slider_order_by ASC";
//        $data = Yii::app()->db->createCommand($sql)->queryAll();
        
        $this->render('index', array(
            'data' => $data,
        ));
        
    }
    
    public function actionError() {
        if ($error = Yii::app()->errorHandler->error) {
            if (Yii::app()->request->isAjaxRequest)
                echo $error['message'];
            else
                $this->render('error', $error);
        }
    }

    public function actionLogout() {
        Yii::app()->user->logout();
        $this->redirect(Yii::app()->homeUrl);
    }

}
